home *** CD-ROM | disk | FTP | other *** search
- Path: lasernet.com!jonathan_wooldridge
- Newsgroups: comp.lang.c
- Message-ID: <60131010101$71C7@lasernet.com>
- X-Gateway: Act-Up 4.6 31 Jan 96 01:01:01 LaserNet
- Date: Tue, 30 Jan 96 23:36:34 LOC
- Organization: 1BBS ■ Imperial Beach CA ■ 619∙429∙6521/6123 ■ (52:1000/153)
- From: Jonathan Wooldridge <jonathan_wooldridge@lasernet.com>
- Subject: Plasma
-
- Greetings!
- I'm trying to create a plasma field, using a recursive algorithm.
-
- /*\
- |*| Given four point rectangle
- |*| fill with random gradiant colors
- \*/
- void plasma(int x1, int y1, int x2, int y2, int TotalColor, int depth){
-
- TotalColor ???? // don't know what to put here.
-
- int midx = (x1+x2)/2; // used for subdividing the rectangle
- int midy = (y1+y2)/2;
-
- if(depth--){ // reduce depth each pass, done on 0
- plasma(x1,y1, midx,midy, TotalColor, depth); // upper left quadrant
- plasma(midx,y1, x2,midy, TotalColor, depth); // upper right quadrant
- plasma(x1,midy, midx,y2, TotalColor, depth); // lower left quadrant
- plasma(midx,midy x2,y2, TotalColor, depth); // lower right quadrant
- }
- else{ // maximum depth reached; fill in remaining area.
- drwfillbox(SET, x1,y1, x2,y2, TotalColor);
- };
- };
-
- Anyway, you get the general idea. Point is, I'm not sure how to go about
- changing the color value, so that it is the average value of the
- outer ones, modified by some random.
-
- I've tried TotalColor += (random(255)+1)/level where level is the
- final depth, but this gives a rather cubic looking field. Pretty tho.
- Anyway, I'm trying to achieve a smooth gradient.
-
- Note that I could also have put the draw routine as four pixels, in
- each pass, and then test for adjacent pixels, to bail the loop.
- Any suggestions on approach?
-
- -SpyroGyra
- ---
- ■ TLX v4.00 ■ Compile, run, curse... Recompile, rerun, recurse...
-
- ---
-